import http from '../../utils/httpRequest'

export default {
  /**
   * 插入一个完整的商品
   * */
  addSpuToProduct (data) {
    return http({
      url: `/pms/spuinfo/product/spuAdd`,
      method: 'post',
      data
    })
  },
  /**
   * 条件搜索一个商品
   * */
  searchSpuByCondition (searchObj, currentIndex, size, catalogId, brandId, publishStatus, spuName, id) {
    return http({
      url: `/pms/spuinfo/searchSpuByCondition/${currentIndex}/${size}`,
      method: 'post',
      data: searchObj ? searchObj : {
        brandId,
        catalogId,

        publishStatus,
        // "spuDescription": "string",
        spuName,
        id,
        // "weight": 0
      }
    })
  },
  update (id, publishStatus, skuId, brandId, catalogId, spuDescription, spuName, weight) {
    return http({
      url: `/pms/spuinfo/update`,
      method: 'post',
      data: {
        brandId,
        catalogId,
        id,
        publishStatus,
        spuDescription,
        spuName,
        weight
      }
    })
  },
  /**
   *
   * 通过categoryId查询出该类型的spu能绑定的attrGroup和attr，再通过spuInfoId查询出其绑定的值，填充到刚刚的attr中，
   * 其中categoryId通过查询出来的skuInfo获得
   * */
  querySpuInfoAttrValueAndFillIntoAttrGroup(spuInfoId){
    return http({
      url:`/pms/attrgroup/querySpuInfoAttrValueAndFillIntoAttrGroup/${spuInfoId}`,
      method:'get'
    });
  },

  /**
   * 根据当前页和每页显示的记录数来获取spuInfo分页列表
   * @param currentPage
   * @param size
   * @returns {*}
   */
  getSpuList(currentPage,size,spuId){
    return http({
      url:`/pms/spuinfo/list/${currentPage}/${size}`,
      method:"get",
      params:{
        spuId:spuId
      }
    });
  }
}
